using ExampleWebApplication.Entities;
using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Conformist;

namespace ExampleWebApplication.Infraestruture.NHibernate.EntityMappings
{
    public class ShipperMap : ClassMapping<Shipper>
    {
        public ShipperMap()
        {
            Table("Shippers");
            Id(x => x.ShipperID, map => { map.Generator(Generators.Identity); map.Column("ShipperID"); });
            Property(x => x.CompanyName, map => { map.Column("CompanyName"); map.NotNullable(true); map.Length(40); });
            Property(x => x.Phone, map => { map.Column("Phone"); map.Length(24); });
            Bag(x => x.Orders, map => { map.Inverse(true); map.Key(key => key.Column("ShipVia")); }, rel => rel.OneToMany());
        }
    }
}
